//
//  XRSelfEditNickNameViewController.m
//  XClassRoom
//
//  Created by NeiQuan on 16/11/8.
//  Copyright © 2016年 Mr-yuwei. All rights reserved.
//

#import "XRSelfEditNickNameViewController.h"
#import "XRPlaceHolderTextView.h"

@interface XRSelfEditNickNameViewController ()
{
    XRPlaceHolderTextView   *_textView;
    
}
@end

@implementation XRSelfEditNickNameViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
-(void)addNavbarView
{
    __weak typeof(self)weakself=self;
    UIButton  *Rightbutton=[UIButton buttonWithType:UIButtonTypeCustom];
    [Rightbutton setFrame:CGRectMake(0, 0, 35, 35)];
    [Rightbutton setTitle:@"完成" forState:UIControlStateNormal];
    Rightbutton .titleLabel.font=[UIFont systemFontOfSize:13];
    [Rightbutton setTitleColor:kWhiteColor forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:Rightbutton];
    [Rightbutton addTarget:weakself action:@selector(clickEndButton:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)addOwnViews
{
    [self.view setBackgroundColor:[UIColor colorWithNSString:@"f2f2f2"]];
    _textView=[[XRPlaceHolderTextView alloc] init];
    _textView.layer.borderColor=kWhiteColor.CGColor;
    _textView.layer.borderWidth=0.7;
    _textView.layer.masksToBounds=YES;
    _textView.layer.cornerRadius=5;
    _textView.placeHolder=_placeHolder;
    [_textView setFrame:CGRectMake(15, 30, kMainScreenWidth-30, 150)];
    [self.view addSubview:_textView];
}
//需要根据UI提供的
-(void)clickEndButton:(UIButton *)sender
{
    //正则匹配
    [self.view endEditing:YES];
    if (_editType==XREditControllerNickType)
    {
        if (_textView.text.length==0)
        {
           //[self.view showMBErrorMessage:@"请输入用户名" inView:self.view];
           return;
        }else if (_textView.text.length<3||_textView.text.length>20)
        {
            //[self showMBErrorMessage:@"字数3-20字" inView:self.view];
            return;
        }
    }else
    {
        if (_textView.text.length==0)
        {
            //[self showMBErrorMessage:@"请输入自我介绍" inView:self.view];
            return;
        }else if (_textView.text.length<3||_textView.text.length>20)
        {
           // [self showMBErrorMessage:@"字数3-20字" inView:self.view];
            return;
        }
    }
    if (_endBlock)
    {
        _endBlock(_textView.text);
    }
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
